import Vue from 'vue'
import VueRouter from "vue-router";

// 解决路由push、replace重复推送报错问题-将错误导出
const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
VueRouter.prototype.replace = function replace(location) {
    return originalReplace.call(this, location).catch(err => err)
}

export default function (routes) {
    Vue.use(VueRouter);
    const routerApp = new VueRouter({
        mode: 'hash',
        routes
    })
    return routerApp
}
